package com.antler.smt.portal.controller;

import com.antler.smt.response.base.Result;
import com.antler.smt.utils.LogUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.*;

/**
 * @author zhangyi
 * @date 2018/5/30 9:11
 */
@RestController
@RequestMapping("/orderList")
@Api(description = "首页滚动的句子集合")
public class RollShamOrderController {

    /**
     * 日志
     */
    private static Logger log = LogUtil.get();

    /**
     * 投放订单列表
     *
     * @return
     */
    @GetMapping("/getShamOrderList")
    @ApiOperation(value = "投放订单列表", httpMethod = "GET")
    public Result getShamOrderList() throws IOException{
        Result result = null;
            File file = ResourceUtils.getFile("classpath:orderList/orderList.txt");
            FileInputStream fileInputStream = new FileInputStream(file);
            BufferedReader reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(fileInputStream)));
            String s = "";
            StringBuffer stringBuffer = new StringBuffer("");
            while((s = reader.readLine()) != null){
                stringBuffer.append(s+",");
            }
            String[] split = stringBuffer.toString().split(",");
            result = new Result(split);
        return result;
    }
}
